var iptVal = document.getElementById("lengInput");
var pwd = document.getElementById('showPwd');
function generatePassword(len) {
  var charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~!@#$%^&*()_+/*-",
    retVal = "";
  for (var i = 0, n = charset.length; i < len; ++i) {
    retVal += charset.charAt(Math.floor(Math.random() * n));
  }
  return retVal;
}
function confirmIpt() {
  if (!/^[0-9]\d*$/.test(iptVal.value)) {
    alert('请输入正整数!');
    return
  }
  pwd.innerText = generatePassword(iptVal.value);
  }